package com.distributer.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.distributer.product.model.Test;
import com.distributer.product.service.TestService;

@Controller
@RequestMapping("/test")
public class TestController {
	
	@Autowired
	private TestService testService;
	
	@RequestMapping(value="/add/{name}/{dec}")
	@ResponseBody
	public void add(@PathVariable(value="name")String name,@PathVariable(value="dec")String dec){
		Test test = new Test(name, dec);
		testService.add(test);
	}

	@RequestMapping(value="/find/{id}")
	@ResponseBody
	public Test find(@PathVariable(value="id")Integer id){
		Test test = testService.find(id);
		return test;
	}
}
